#    pythonequations is a collection of equations expressed as Python classes
#    Copyright (C) 2008 James R. Phillips
#    2548 Vera Cruz Drive
#    Birmingham, AL 35235 USA
#    email: zunzun@zunzun.com
#
#    License: BSD-style (see LICENSE.txt in main source directory)
#    Version info: $Id: Power.py 274 2010-09-29 13:16:14Z zunzun.com $

import pythonequations, pythonequations.EquationBaseClasses, pythonequations.ExtraCodeForEquationBaseClasses
import numpy
numpy.seterr(all = 'raise') # numpy raises warnings, convert to exceptions to trap them


class PowerA3D(pythonequations.EquationBaseClasses.Equation3D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name ="Power A"
    _HTML = "z = a * (x<SUP>b</SUP> + y<SUP>c</SUP>)"
    coefficientDesignatorTuple = ("a", "b", "c")
    function_cpp_code = 'temp = coeff[0] * (pow(_id[_cwo[0]+i], coeff[1]) + pow(_id[_cwo[1]+i], coeff[2]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Y(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a * (pow(x_in, b) + pow(y_in, c));\n"
        return s



class PowerA_Transform3D(pythonequations.EquationBaseClasses.Equation3D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name ="Power A Transform"
    _HTML = "z = a * ((dx + f)<SUP>b</SUP> + (gy + h)<SUP>c</SUP>)"
    coefficientDesignatorTuple = ("a", "b", "c", 'd', 'f', 'g', 'h')
    function_cpp_code = 'temp = coeff[0] * (pow(coeff[3] * _id[_cwo[0]+i] + coeff[4], coeff[1]) + pow(coeff[5] * _id[_cwo[1]+i] + coeff[6], coeff[2]));'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Y(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a * (pow(d * x_in + f, b) + pow(g * y_in + h, c));\n"
        return s



class PowerB3D(pythonequations.EquationBaseClasses.Equation3D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name ="Power B"
    _HTML = "z = a + x<SUP>b</SUP> + y<SUP>c</SUP>"
    coefficientDesignatorTuple = ("a", "b", "c")
    function_cpp_code = 'temp = coeff[0] + pow(_id[_cwo[0]+i], coeff[1]) + pow(_id[_cwo[1]+i], coeff[2]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Y(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a + pow(x_in, b) + pow(y_in, c);\n"
        return s



class PowerB_Transform3D(pythonequations.EquationBaseClasses.Equation3D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name ="Power B Transform"
    _HTML = "z = a + (dx + f)<SUP>b</SUP> + (gy + h)<SUP>c</SUP>"
    coefficientDesignatorTuple = ("a", "b", "c", 'd', 'f', 'g', 'h')
    function_cpp_code = 'temp = coeff[0] + pow(coeff[3] * _id[_cwo[0]+i] + coeff[4], coeff[1]) + pow(coeff[5] * _id[_cwo[1]+i] + coeff[6], coeff[2]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Y(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a + pow(d * x_in + f, b) + pow(g * y_in + h, c);\n"
        return s



class PowerC3D(pythonequations.EquationBaseClasses.Equation3D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name ="Power C"
    _HTML = "z = a + x<SUP>b</SUP> * y<SUP>c</SUP>"
    coefficientDesignatorTuple = ("a", "b", "c")
    function_cpp_code = 'temp = coeff[0] + pow(_id[_cwo[0]+i], coeff[1]) * pow(_id[_cwo[1]+i], coeff[2]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Y(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a + pow(x_in, b) * pow(y_in, c);\n"
        return s



class PowerC_Transform3D(pythonequations.EquationBaseClasses.Equation3D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = False
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name ="Power C Transform"
    _HTML = "z = a + (dx + f)<SUP>b</SUP> * (gy + h)<SUP>c</SUP>"
    coefficientDesignatorTuple = ("a", "b", "c", 'd', 'f', 'g', 'h')
    function_cpp_code = 'temp = coeff[0] + pow(coeff[3] * _id[_cwo[0]+i] + coeff[4], coeff[1]) * pow(coeff[5] * _id[_cwo[1]+i] + coeff[6], coeff[2]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Y(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a + pow(d * x_in + f, b) * pow(g * y_in + h, c);\n"
        return s



class PowerD3D(pythonequations.EquationBaseClasses.Equation3D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name ="Power D"
    _HTML = "z = ax<SUP>b</SUP> + cy<SUP>d</SUP>"
    coefficientDesignatorTuple = ("a", "b", "c", "d")
    function_cpp_code = 'temp = coeff[0] * pow(_id[_cwo[0]+i], coeff[1]) + coeff[2] * pow(_id[_cwo[1]+i], coeff[3]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Y(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a * pow(x_in, b) + c * pow(y_in, d);\n"
        return s



class PowerD_Transform3D(pythonequations.EquationBaseClasses.Equation3D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name ="Power D Transform"
    _HTML = "z = a(fx + g)<SUP>b</SUP> + c(hy + i)<SUP>d</SUP>"
    coefficientDesignatorTuple = ("a", "b", "c", "d", 'f', 'g', 'h', 'i')
    function_cpp_code = 'temp = coeff[0] * pow(coeff[4] * _id[_cwo[0]+i] + coeff[5], coeff[1]) + coeff[2] * pow(coeff[6] * _id[_cwo[1]+i] + coeff[7], coeff[3]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Y(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a * pow(f * x_in + g, b) + c * pow(h * y_in + i, d);\n"
        return s



class PowerE3D(pythonequations.EquationBaseClasses.Equation3D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name ="Power E"
    _HTML = "z = a * x<SUP>b</SUP> * y<SUP>c</SUP>"
    coefficientDesignatorTuple = ("a", "b", "c")
    function_cpp_code = 'temp = coeff[0] * pow(_id[_cwo[0]+i], coeff[1]) * pow(_id[_cwo[1]+i], coeff[2]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Y(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a * pow(x_in, b) * pow(y_in, c);\n"
        return s



class PowerE_Transform3D(pythonequations.EquationBaseClasses.Equation3D):
    RequiresAutoGeneratedGrowthAndDecayForms = True
    RequiresAutoGeneratedOffsetForm = True
    RequiresAutoGeneratedReciprocalForm = True
    RequiresAutoGeneratedInverseForms = True
    _name ="Power E Transform"
    _HTML = "z = a * (dx + f)<SUP>b</SUP> * (gy + h)<SUP>c</SUP>"
    coefficientDesignatorTuple = ("a", "b", "c", 'd', 'f', 'g', 'h')
    function_cpp_code = 'temp = coeff[0] * pow(coeff[3] * _id[_cwo[0]+i] + coeff[4], coeff[1]) * pow(coeff[5] * _id[_cwo[1]+i] + coeff[6], coeff[2]);'


    def CreateCacheGenerationList(self):
        self.CacheGenerationList = []
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_X(NameOrValueFlag=1), []])
        self.CacheGenerationList.append([pythonequations.ExtraCodeForEquationBaseClasses.CG_Y(NameOrValueFlag=1), []])

    def SpecificCodeCPP(self):
        s = "\ttemp = a * pow(d * x_in + f, b) * pow(g * y_in + h, c);\n"
        return s
